﻿/*----------------------------------------------------------------
  //Copyright (C) 2012 赵国伟
  //文件功能描述：订单管理Ajax请求服务端处理程序。
  //创建人：赵国伟
  //生成时间：2012/04/18 16:15:00
//----------------------------------------------------------------*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Shopping.Common;
using Shopping.Model;
using Shopping.BLL;

public partial class Manage_AS_OrdersCommon :BaseManagePage
{

    private readonly OrdersManage bllOrders = new OrdersManage();

    protected void Page_Load(object sender, EventArgs e)
    {

        if (!Page.IsPostBack)
        {
            string action = Request.QueryString["Action"] as string;

            switch (action)
            {
                case "SaveOrder": //保存订单信息； by 赵国伟 2012-06-11
                    SaveOrder();
                    break;
                case "GetOrderInfo": //查询一条指定的订单信息；by 赵国伟 2012-06-11
                    GetOrderInfo();
                    break;
                case "DeleteOrder":  //删除一条指定的订单信息；by 赵国伟 2012-06-11
                    DeleteOrder();
                    break;
            }


        }
        Response.End();
    }

    #region "保存一条订单信息； by 赵国伟 2012-06-11"
    /// <summary>
    /// 保存一条订单信息；
    /// </summary>
    private void SaveOrder()
    {
        ReturnValue ret = BLLHelper.Save<OrdersManage, OrderInfo>("SaveOrder");
        Response.Write(ret.ToJsonString());
    }
    #endregion

    #region "查询一条指定的订单信息；by 赵国伟 2012-06-11"
    /// <summary>
    /// 查询一条指定的订单信息；
    /// </summary>
    private void GetOrderInfo()
    {
        int orderID = Utility.G<int>("OrderID");
        OrderInfo o = bllOrders.GetOrder(orderID);
        if (o != null)
            Response.Write(JSONHelper.ObjectToJson<OrderInfo>(o));
    }
    #endregion

    #region "删除一条指定的订单信息；by 赵国伟 2012-06-11"
    /// <summary>
    /// 删除一条指定的订单信息；by 赵国伟 2012-06-11
    /// </summary>
    private void DeleteOrder()
    {
        int orderId = Utility.G<int>("OrderID");
        Response.Write(bllOrders.DeleteOrder(orderId).ToJsonString());
    }
    #endregion


}